home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sources.misc
- subject: v13i086: lj2ps (01 of 12), a LaserJet to PostScript Translator
- From: lishka@uwslh.slh.wisc.edu (Chris Lishka (relaxing in the Mad-City) )
- Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
-
- Posting-number: Volume 13, Issue 86
- Submitted-by: lishka@uwslh.slh.wisc.edu (Chris Lishka (relaxing in the Mad-City) )
- Archive-name: lj2ps/part01
-
- I submit for inclusion in comp.sources.misc the program "lj2ps"
- (revision 1.1, release version), a LaserJet to PostScript translator.
- lj2ps is able to convert a subset of LaserJet PCL 4 that includes page
- motion, page setup, primary font selection, and text. It is not able
- to do macros, position stack commands, graphics (bitmap or
- patterns/grayscale), or downloadable fonts. However, the scanner
- *does* recognize all of the PCL 4 commands, and I have added many
- hooks for the unimplemented commands. Therefore, it should not be
- too difficult to add in the features you need.
-
- Included in this distribution is the source for lj2ps, documentation,
- a test suite, and a metrics suite. The source code for lj2ps is
- should be very portable, and should run on everything from PC's to
- mainframes without much modification (although I have only tried it on
- a 4.3BSD Unix system). Please see the README file (right after the
- manifest below) for more information.
-
- I hope you enjoy it!
-
- .oO Chris Oo.
-
- Christopher Lishka 608-262-4485 "Dad, don't give in to mob mentality!"
- Wisconsin State Lab. of Hygiene -- Bart Simpson
- lishka@uwslh.slh.wisc.edu "I'm not, Son. I'm jumping on the bandwagon."
- uunet!uwvax!uwslh!lishka -- Homer Simpson
-
-
- ---- Cut Here and unpack ----
- #!/bin/sh
- # This is a shell archive (shar 3.21)
- # made 06/30/1990 21:08 UTC by lishka@uwslh.slh.wisc.edu
- # Source directory /usr/10/src/local/lj2ps/DIST
- #
- # existing files will NOT be overwritten
- #
- # This shar contains:
- # length mode name
- # ------ ---------- ------------------------------------------
- # 9916 -rw-rw-r-- README
- # 2518 -rw-r--r-- Makefile
- # 73533 -rw-rw-r-- MetricsSuite/DiagRules
- # 5279 -rw-rw-r-- MetricsSuite/HorizMove
- # 42068 -rw-rw-r-- MetricsSuite/Letters
- # 32131 -rw-rw-r-- MetricsSuite/NumbersAndSymbols
- # 11972 -rw-rw-r-- MetricsSuite/Spaces
- # 267 -rw-rw-r-- MetricsSuite/VertMove
- # 5202 -rw-rw-r-- MetricsSuite/diagrule
- # 748 -rw-rw-r-- MetricsSuite/fonts
- # 335 -rw-rw-r-- MetricsSuite/hmove
- # 2764 -rw-rw-r-- MetricsSuite/letters
- # 2253 -rw-rw-r-- MetricsSuite/numbers.and.symbols
- # 124 -rwxr-xr-x MetricsSuite/run
- # 814 -rw-rw-r-- MetricsSuite/spaces
- # 201 -rw-rw-r-- MetricsSuite/vmove
- # 1236 -rw-rw-r-- TestSuite/ClearMargins
- # 1788 -rw-rw-r-- TestSuite/HMI
- # 425 -rw-rw-r-- TestSuite/HMotion-Cols
- # 454 -rw-rw-r-- TestSuite/HMotion-Decipoints
- # 440 -rw-rw-r-- TestSuite/HMotion-Dots
- # 358 -rw-rw-r-- TestSuite/HalfLineFeed
- # 594 -rw-rw-r-- TestSuite/LinesPerInch
- # 800 -rw-rw-r-- TestSuite/NumberOfCopies
- # 544 -rw-rw-r-- TestSuite/Orientation
- # 7512 -rw-rw-r-- TestSuite/PFontAttributes
- # 368 -rw-rw-r-- TestSuite/PaperInputControl
- # 285 -rw-rw-r-- TestSuite/Reset
- # 1663 -rw-rw-r-- TestSuite/RightLeftMargins
- # 19426 -rw-rw-r-- TestSuite/Tabs
- # 991 -rw-rw-r-- TestSuite/TextLength
- # 571 -rw-rw-r-- TestSuite/TopMargin
- # 334 -rw-rw-r-- TestSuite/Underlining
- # 293 -rw-rw-r-- TestSuite/VHMotion-ColRow
- # 303 -rw-rw-r-- TestSuite/VHMotion-Decipoints
- # 289 -rw-rw-r-- TestSuite/VHMotion-Dots
- # 496 -rw-rw-r-- TestSuite/VMI
- # 642 -rw-rw-r-- TestSuite/VMotion-Decipoints
- # 630 -rw-rw-r-- TestSuite/VMotion-Dots
- # 613 -rw-rw-r-- TestSuite/VMotion-Rows
- # 748 -rw-rw-r-- TestSuite/fonts
- # 154 -rwxr-xr-x TestSuite/run
- # 871 -rw-r--r-- doc/BugFile
- # 12487 -rw-rw-r-- doc/Copying
- # 2980 -rw-r--r-- doc/LogFile
- # 1683 -rw-rw-r-- doc/compile.options.doc
- # 4873 -rw-rw-r-- doc/limitations.doc
- # 4619 -rw-rw-r-- doc/lj2ps.l
- # 657 -rw-rw-r-- doc/measurements.doc
- # 17644 -rw-r--r-- doc/parameter.scanner.idraw
- # 6829 -rw-rw-r-- doc/scanner.doc
- # 3480 -rw-rw-r-- doc/suggestions.doc
- # 3131 -rw-rw-r-- doc/supported.commands.doc
- # 40749 -rw-r--r-- doc/text.scanner.idraw
- # 2950 -rw-r--r-- errors.c
- # 1170 -rw-r--r-- errors.h
- # 20389 -rw-r--r-- lj.c
- # 13148 -rw-r--r-- lj.h
- # 8092 -rw-r--r-- lj2ps.c
- # 1251 -rw-r--r-- lj2ps.h
- # 33110 -rw-r--r-- ljcmds.c
- # 2558 -rw-r--r-- ljcmds.h
- # 16148 -rw-r--r-- ljfonts.c
- # 1258 -rw-r--r-- ljfonts.h
- # 32557 -rw-r--r-- scan.c
- # 3044 -rw-r--r-- scan.h
- # 5589 -rw-r--r-- transform.c
- # 1091 -rw-r--r-- transform.h
- #
- if touch 2>&1 | fgrep '[-amc]' > /dev/null
- then TOUCH=touch
- else TOUCH=true
- fi
- # ============= README ==============
- if test X"$1" != X"-c" -a -f 'README'; then
- echo "File already exists: skipping 'README'"
- else
- echo "x - extracting README (Text)"
- sed 's/^X//' << 'SHAR_EOF' > README &&
- X lj2ps
- X A LaserJet PCL to PostScript Translator
- X
- X Version 1.1 (release)
- X
- X Christopher Lishka
- X Wisconsin State Laboratory of Hygiene
- X Data Processing Department
- X
- X June 30th, 1990
- X
- X
- X Contents:
- X
- X 1. Introduction
- X 2. This Distribution, and How To Create lj2ps
- X 3. Implementation Notes
- X 4. Miscellaneous (Things I Have To Get Off My Chest)
- X 5. Contacting Me
- X
- X
- X1. Introduction
- X
- XThe lj2ps program translates HP LaserJet PCL ("Page Control Language")
- Xto PostScript. Currently it converts a subset of the LaserJet Series
- XII language (PCL 4) to device-independent PostScript.
- X
- Xlj2ps was originally written to allow my organization to "upgrade" our
- XLaserJets to LaserWriters, yet still have a way to print PCL files.
- XDue to a lack of time, not all of PCL is emulated (this is discussed
- Xbelow). I am releasing this program to the "real world" at the
- Xsuggestion of by boss and coworkers, and with the hope that others
- Xwill also find this program useful and may even extend its
- Xcapabilities.
- X
- X
- X2. This Distribution, and How To Create lj2ps
- X
- XIncluded in this distribution are all of the source files for lj2ps,
- Xdocumentation, a test suite, and a metrics suite.
- X
- XAll source files are included in the top level directory, along with
- Xthe Makefile and README file. To create lj2ps, simply type "make".
- XTo clean the directory, type "make clean". Pretty simple, huh? ;-)
- XThere are probably other options in the Makefile, but since I
- Xregularly use "cake" (instead of make), and since I generated it with
- Xmkmf (automatic Makefile creator), I am not sure what they are. Feel
- Xfree to edit it. Those who are interested in the Cakefile, please
- Xcontact me.
- X
- XThe TestSuite directory contains many tests used to check the
- Xcompatibility of lj2ps with real LaserJets. Similarly, the
- XMetricsSuite directory is used to tune lj2ps to produce output which
- Xlooks like LaserJet output. These are discussed in more detail in the
- Ximplementation section below.
- X
- XThe documentation directory has several files in it. Here are
- Xexplanations of them:
- X
- XBugFile Known bugs that affect lj2ps are detailed here. Each
- X entry identifies the date detected, revision affected,
- X and the person logging the bug (usually me!). The
- X LogFile describes which bugs have been fixed.
- X
- XCopying This is the standard Free Software Foundation
- X copyleft. lj2ps is distributed according to these
- X restrictions. Please look through it so that you are
- X familiar with the conditions of use for lj2ps. The
- X only other thing that I ask is that you send me
- X changes (with descriptions) if you make them, so that
- X I can benefit from your work.
- X
- XLogFile This file contains descriptions of each revision of
- X lj2ps. All changes including bug fixes, added
- X features, and removals are detailed here.
- X
- Xcompile.options.doc
- X Options are available at compile-time to conditionally
- X include or exclude features when the program is
- X created. This file describes the options currently
- X available.
- X
- Xlimitations.doc Any program worth its salt has certain limitations.
- X lj2ps is no exception. This file lists some that I
- X know about. Feel free to fix any (or all) of them.
- X
- Xlj2ps.l The man page for lj2ps, to be installed in
- X /usr/man/manl. Use the command "nroff -man lj2ps.l"
- X to create the documentation file.
- X
- Xmeasurements.doc
- X One of the worst aspects of LaserJets is the many
- X different measurements used by different commands,
- X This file lists all measurements that I know of.
- X
- Xparameter.scanner.idraw
- X A diagram of the parameter scanner. This file was
- X produced with the drawing program "idraw," and can be
- X printed on any PostScript printer.
- X
- Xscanner.doc
- X There are two distinct (yet related) scanners used in
- X lj2ps. Scanner.doc describes the conceptual design I
- X used in creating them, which is derived from standard
- X scanner and finite state automata theory taught in
- X college (where do you think I learned it from? ;-).
- X
- Xsuggestions.doc This file lists aspects of lj2ps that need work. It
- X may also provide some insight as to how lj2ps was
- X designed. If you have some free time, and need some
- X suggestions on how to improve the program, then look
- X here.
- X
- Xsupported.commands.doc
- X As detailed below, I did not have time to emulate all
- X PCL commands. This list shows which ones are (and
- X are not) supported.
- X
- Xtext.scanner.idraw
- X A diagram of the text scanner. This file was produced
- X with the drawing program "idraw," and can be printed
- X on any PostScript printer.
- X
- X
- X3. Implementation Notes
- X
- XThe program is written completely in K&R C (although not ANSI), and
- Xthe C code should compile on nearly every standard machine out there.
- XTo my knowledge, I have not used any "strange" C operators or
- Xcombinations, so this program should work on anything from a PC to a
- Xsuper-computer.
- X
- XI built the program with the idea of emulating full LJII PCL, so all
- Xof the actual command syntax is parsed. However, I have only
- Ximplemented the commands which I needed. Left out are graphics,
- Xmacros, and soft font commands (among others). It should not be that
- Xhard to add features to this program, and I have included variables
- X(some yet unused) for most (if not all) aspects of LaserJet operation.
- XFeel free to work on extending this program to emulate the unfinished
- XPCL commands, as well as fixing some of the inconsistencies that will
- Xlikely pop up. All I ask is that you send me any changes that you
- Xmake, so I can add the same features to my own version (my address is
- Xlisted at the end of this file.
- X
- XI have designed lj2ps with efficiency in mind. To this end, I
- Xhand-coded the scanner in C instead of generating it with Lex. I have
- Xalso spent some time profiling the execution. Although one major
- Xbottleneck has been fixed, most of the program actually runs at a
- Xreasonable rate. As would be expected, much of the execution time is
- Xspent in the scanner and _doprnt. The scanner could likely be sped up
- Xsome more (a colleague suggests "caching" several variables in
- Xregisters), but I have left this for the future.
- X
- XI have also designed the program with accuracy in mind. Included in
- Xthis distribution are two suites of files: one for testing, the other
- Xfor accurate reproduction. The test suite is an attempt at providing
- Xtest files which will exercise critical and nit-picky features of
- XLaserJet Series II printers. It is by no means complete. I have only
- Xincluded tests for features that are needed at our organization, and I
- Xhave likely even left out some of these. I encourage you to add more
- Xfiles to the test suite; if several people contribute, a nice
- Xcollection could be created. The metrics suite provides print samples
- Xwhich highlight different measurements. For instance, you could test
- Xinter-line spacing by printing the appropriate metrics file on a
- XLaserJet and a PostScript printer, and then tweak lj2ps to match the
- XLaserJet's output. This suite is also not complete, so feel free to
- Xadd more files.
- X
- X
- X4. Miscellaneous (Things I Have To Get Off My Chest)
- X
- XIt is unlikely that I will have any time at work to finish this
- Xprogram. I will only support it locally for our own users. Although
- Xit would be nice to work on this outside of my job, I have so many
- Xother program (and non-program) ideas that I likely won't do much more
- Xwith lj2ps. Therefore it is up to you to build in the missing
- Xfunctionality that you want.
- X
- XEven though the major reason I wrote this was because our organization
- Xneeded it, a significant driving-force for me was a "proof of
- Xconcept." I always thought that PostScript was a much better language
- Xthan LaserJet PCL, and this program provided me with a way to prove
- Xit. Even though this revision of lj2ps is limited, I am convinced
- Xthat one could fully emulate a LaserJet with a filter (like lj2ps) and
- Xa PostScript printer. In fact, I bet it could be done with PostScript
- Xalone, although it would be incredibly slow. However, one cannot
- Xemulate a PostScript printer using PCL. Most (if not all) PostScript
- Xto LaserJet emulators are programs (in software or hardware) which
- Xsend bitmaps to a LaserJet; PCL is pretty-much bypassed. This says a
- Xlot about the two languages.
- X
- XI have spent several years writing programs which use PCL on
- XLaserJets. I have just finished a translator that parses and emulates
- XPCL. With all this experience and time spent using PCL, all I can say
- Xis that it leaves a really bad taste in my mouth. It is not user
- Xfriendly, not consistent, and not robust. Its syntax is lousy, its
- Xcommands are impossible to remember, and it inner workings are very
- Xhard to figure out (believe me, I spent too much time doing this!).
- XWhoever is responsible for developing PCL ought to be taught a lesson.
- XI have much respect for many Hewlett Packard products (like the hp28s
- Xand hp48sx calculators). However, the LaserJet's language is one of
- XHP's worst creations. Suffice it to say that the HP LaserJet is the
- XIBM PC of the laser-printer world.
- X
- X
- X5. Contacting Me
- X
- XIf you have any additions, fixes, or problems; need to know more about
- Xthe secret workings of the code; have suggestions for improving lj2ps;
- Xor simply want to say hello, you can contact me at:
- X
- X Internet: lishka@uwslh.slh.wisc.edu
- X UUCP: ...!uunet!uwvax!uwslh!lishka
- X
- X Work phone: (608) 262-4485 (Tues.-Sat., 5am-9pm)
- X
- X Address: Christopher Lishka
- X Data Processing Dept.
- X Wisconsin State Laboratory of Hygiene
- X 465 Henry Mall
- X Madison, WI 53715
- X
- XMy only real request is that you send me any bug fixes, enhancements,
- Xor other modifications that you have made. Please don't send source
- Xtrees without contacting me first. The best thing to send is a
- Xcontext-diff (e.g. for "patch") from some released version.
- X
- XIf you like this program enough to donate some money, then I ask that
- Xyou give it to charity (for example: an environmental, peace, or
- Xhomeless organization). It will make both of us feel good, and it is
- Xeven tax-deductible.
- SHAR_EOF
- $TOUCH -am 0630160890 README &&
- chmod 0664 README ||
- echo "restore of README failed"
- set `wc -c README`;Wc_c=$1
- if test "$Wc_c" != "9916"; then
- echo original size 9916, current size $Wc_c
- fi
- fi
- # ============= Makefile ==============
- if test X"$1" != X"-c" -a -f 'Makefile'; then
- echo "File already exists: skipping 'Makefile'"
- else
- echo "x - extracting Makefile (Text)"
- sed 's/^X//' << 'SHAR_EOF' > Makefile &&
- X# Project: lj2ps, LaserJet PCL to PostScript translator
- X# File: Makefile
- X#
- X# Author: Christopher Lishka
- X# Organization: Wisconsin State Laboratory of Hygiene
- X# Data Processing Department
- X#
- X# Note: I use "cake" instead of "make" to build the lj2ps program from its
- X# source files. However, because cake isn't as popular as make, I
- X# have included this Makefile in the general distribution. Anyone who
- X# would like the Recipe file for cake can contact me. However, it is
- X# heavily dependent on my working style, and may not suit everyone's
- X# tastes. - Chris
- X#
- X# Possible CFLAGS options:
- X#
- X# -DDEBUG Compile in diagnostic print code
- X# -DVERBOSE_WARNINGS More types of warnings are printed
- X
- XPROGRAM = lj2ps
- X
- XCFLAGS = -O
- X
- XLDFLAGS = -O
- X
- XLIBS = -lm
- X
- XLINKER = cc
- X
- X# ----------------------------------------------------------------------
- X
- XDEST = .
- X
- XEXTHDRS = /usr/include/ctype.h \
- X /usr/include/math.h \
- X /usr/include/stdio.h \
- X /usr/include/strings.h
- X
- XHDRS = errors.h \
- X lj.h \
- X lj2ps.h \
- X ljcmds.h \
- X ljfonts.h \
- X scan.h \
- X transform.h
- X
- XOBJS = errors.o \
- X lj.o \
- X lj2ps.o \
- X ljcmds.o \
- X ljfonts.o \
- X scan.o \
- X transform.o
- X
- XSRCS = errors.c \
- X lj.c \
- X lj2ps.c \
- X ljcmds.c \
- X ljfonts.c \
- X scan.c \
- X transform.c
- X
- XMAKEFILE = Makefile
- X
- XPRINT = pr
- X
- X# ----------------------------------------------------------------------
- X
- Xall: $(PROGRAM)
- X
- X$(PROGRAM): $(OBJS)
- X @echo -n "Loading $(PROGRAM) ... "
- X @$(LINKER) $(LDFLAGS) $(OBJS) $(LIBS) -o $(PROGRAM)
- X @echo "done"
- X
- Xclean:; @rm -f $(OBJS)
- X
- Xdepend:; @mkmf -f $(MAKEFILE) PROGRAM=$(PROGRAM) DEST=$(DEST)
- X
- Xindex:; @ctags -wx $(HDRS) $(SRCS)
- X
- Xinstall: $(PROGRAM)
- X @echo Installing $(PROGRAM) in $(DEST)
- X @install -s $(PROGRAM) $(DEST)
- X
- Xprint:; @$(PRINT) $(HDRS) $(SRCS)
- X
- Xprogram: $(PROGRAM)
- X
- Xtags: $(HDRS) $(SRCS); @ctags $(HDRS) $(SRCS)
- X
- Xupdate: $(DEST)/$(PROGRAM)
- X
- X$(DEST)/$(PROGRAM): $(SRCS) $(LIBS) $(HDRS) $(EXTHDRS)
- X @make -f $(MAKEFILE) DEST=$(DEST) install
- X###
- Xerrors.o: /usr/include/stdio.h errors.h lj2ps.h lj.h
- Xlj.o: /usr/include/stdio.h lj.h ljcmds.h ljfonts.h scan.h lj2ps.h
- Xlj2ps.o: /usr/include/stdio.h /usr/include/math.h lj2ps.h lj.h transform.h \
- X errors.h
- Xljcmds.o: /usr/include/stdio.h /usr/include/math.h ljcmds.h lj.h ljfonts.h \
- X scan.h lj2ps.h
- Xljfonts.o: /usr/include/strings.h ljfonts.h lj.h
- Xscan.o: /usr/include/stdio.h /usr/include/ctype.h scan.h lj.h lj2ps.h
- Xtransform.o: /usr/include/stdio.h transform.h scan.h lj2ps.h lj.h
- SHAR_EOF
- $TOUCH -am 0630160790 Makefile &&
- chmod 0644 Makefile ||
- echo "restore of Makefile failed"
- set `wc -c Makefile`;Wc_c=$1
- if test "$Wc_c" != "2518"; then
- echo original size 2518, current size $Wc_c
- fi
- fi
- echo "End of part 1, continue with part 2"
- exit 0
-
-